home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Sherlock 2.0
/
DevLibSrc
/
Mac DevLib
/
mac_dialog_util.c
< prev
next >
Wrap
Text File
|
1995-09-25
|
3KB
|
141 lines
/*
devlib: dialog utility routines.
source: mac_dialog_util.c
started: November 30, 1990.
version:
September 25, 1995:
Changed qd.white to &qd.white.
Changed qd.black to &qd.black.
*/
#include <LIBlib.h>
#include <LIBdialog.h>
#include <Quickdraw.h>
#define slot1 1 /* Dialog item 1 */
#define slot2 2 /* Dialog item 2 */
/*
Center the indicated rectangle on the screen.
Warning: this code assumes the width of the dialog
is less than the width of the screen.
The dialog will "disappear" if this is not so.
*/
#define b (qd.screenBits.bounds)
/*
Center a dialog on the screen.
*/
void
center_dialog(DialogPtr dp)
{
Rect r;
r.top = dp -> portRect.top;
r.left = dp -> portRect.left;
r.bottom = dp -> portRect.bottom;
r.right = dp -> portRect.right;
r.top = ((b.bottom - b.top) - (r.bottom - r.top)) / 2;
r.left = ((b.right - b.left) - (r.right - r.left)) / 2;
MoveWindow(dp, r.left, r.top, TRUE);
}
#undef b
/*
Return the value of the indicated dialog item.
5/30/91: item changed to short.
*/
int
getControl(DialogPtr dp, short item)
{
Rect tempRect;
short DType;
Handle DItem;
GetDItem(dp, item, &DType, &DItem, &tempRect);
return GetCtlValue((ControlHandle) DItem);
}
/*
Hilite the default button in slot 1.
*/
void
hiliteButton(DialogPtr dp)
{
Rect tempRect;
short DType;
Handle DItem;
GetDItem(dp, slot1, &DType, &DItem, &tempRect);
PenSize(3, 3);
InsetRect(&tempRect, -4, -4);
FrameRoundRect(&tempRect, 16, 16);
PenSize(1, 1);
}
/*
Hilite the default button in slot 1 and unhilite the button in slot 2.
*/
void
hilite2Buttons(DialogPtr dp)
{
Rect tempRect;
short DType;
Handle DItem;
/* Highlight the item in the first slot. */
GetDItem(dp, slot1, &DType, &DItem, &tempRect);
PenPat(&qd.black);
PenSize(3, 3);
InsetRect(&tempRect, -4, -4);
FrameRoundRect(&tempRect, 16, 16);
PenSize(1, 1);
/* Unhighlight the item in the second slot. */
GetDItem(dp, slot2, &DType, &DItem, &tempRect);
PenPat(&qd.white);
PenSize(3, 3);
InsetRect(&tempRect, -4, -4);
FrameRoundRect(&tempRect, 16, 16);
PenSize(1, 1);
PenPat(&qd.black);
}
/*
Hilight or UnHilight the indicated control item.
WARNING: Static text and Edit text are NOT, repeat NOT, controls.
The program will crash if you try to "unhilite" these!!
*/
void
hiliteControl(DialogPtr dp, short item, int value)
{
Rect tempRect;
short DType;
Handle DItem;
GetDItem(dp, item, &DType, &DItem, &tempRect);
HiliteControl((ControlHandle) DItem, value);
}
/*
Set the indicated item to the indicated value.
*/
void
setControl(DialogPtr dp, short item, int value)
{
Rect tempRect;
short DType;
Handle DItem;
GetDItem(dp, item, &DType, &DItem, &tempRect);
SetCtlValue((ControlHandle) DItem, value);
}